from tkinter import *
from gnn import GnnFrame
import tkinter as tk
import os


root = tk.Tk()
root.title('条码采集')
root.geometry("800x700")
def add_config():

    import json
    basic_info={
        'DB_NAME':'TiaoMa',
        'DB_UID':'root',
        'DB_PWD':'rootroot',
        'DB_HOST':'localhost',
        'DB_PORT':3306,
        'TABLE_COMPANY_LOGIN':'CompanyLogin',
        'TABLE_COMPANY_LOGOUT':'CompanyLogout',
        'TABLE_COMPANY_INFO':'CompanyInfo',
        'TABLE_NAME_SELECT':'CompanyLogin',
        'TABLE_INFO_SELECT':'CompanyInfo',
        'LAST_CJ_PAGE':1,
        "CJ_NAME_MAX_PAGE": 100,
        'LAST_CJ_TYPE':0,
        'CJ_NAME_LOOP':0,
        "CJ_NAME_LOOP_SLEEP":24,
        'CJ_NAME_TIMING':0,
        'CJ_INFO_TIMING':0
    }
    if not os.path.exists('config.json'):
        with open('config.json','w',encoding='utf-8') as f:
            json.dump(basic_info,f,ensure_ascii=False,indent=4)     
    else:
        with open('config.json','r',encoding='utf-8') as f:
            old_basic_info=json.load(f)

        for k,v in basic_info.items():
            if old_basic_info.get(k) is None:
                old_basic_info[k]=v 

        with open('config.json','w',encoding='utf-8') as f:
            json.dump(old_basic_info,f,ensure_ascii=False,indent=4)     

add_config()
f0=GnnFrame(root)
f0.pack(fill=X)


if __name__=='__main__':
    
    root.mainloop()